import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
  {
    path:'/login',
    name:'login',
    component: () => import(/**webpackChunkName:"login" */ '../views/login/login.vue')
  },
  {
    path:'/home',
    name:'home',
    component: () => import(/* webpackChunkName: "home" */ '../views/home/home.vue')
  }
]
// router.beforeEach((to, from, next) => {
//   // to 去哪
//   // from 从哪来
//   // next 继续
//   let token = window.sessionStorage.getItem('token')
//   if(!token && to.path == "/login"){
//     return next('/login')
//   }
//   next()
// }
// )
const router = new VueRouter({
  routes
})

export default router
